﻿
Ext.define('app.controller.App', {
    extend: 'Ext.app.Controller',
    alias: 'controller.app',
    views: [
        'app.main.region.Center'
    ],
    routes: {
        'home': {
            action: 'onHome'
        },
        'app.prm.detail.Index/:id': {
            action: 'onPrmDetail'
        },
        'openmenu/:module': {
            action: 'onOpenMenu'
        },
        'app.prm.document.Index/:id': {
            action: 'onOpenDocument'
        },
        'app.prm.detail.Discuss/:id': {
            action: 'onOpenDiscuss'
        }
    },
    init: function () {
        this.addRef([{
            ref: 'maincenter',
            selector: '[xtype=maincenter]'
        }]);
        this.callParent();
    },
    onPrmDetail: function (id) {
        var tabPanel = this.getMaincenter();
        tabPanel.newTab(id, "app.prm.detail.Index", "项目首页");
    },
    onOpenDocument: function (id)
    {
        var tabPanel = this.getMaincenter();
        tabPanel.newTab(id, "app.prm.document.Index", "项目文档");
    },
    onOpenDiscuss: function (id)
    {
        var tabPanel = this.getMaincenter();
        tabPanel.newTab(id, "app.prm.detail.Discuss", "项目讨论");
    },
    onOpenMenu: function (module) {
        
        var text = Ext.util.Cookies.get(module);
        var url = module.split('-').join('.')

        var tabPanel = this.getMaincenter();
        var _itemid = 'm_' + new Date().getTime();

        tabPanel.newTab(_itemid, url, text);
    },
    onHome: function () { }
});
